<?php
/**
 * Created by PhpStorm.
 * User: PanChaoZhi
 * Date: 2017/1/21
 * Time: 17:34
 */
session_start();
require_once './lib/mysqli_func.php';
$conn = new MySQL();
/*$sql = "select * from imooc_pro limit 2";
$result = $conn->fetchAll($sql);
echo '<pre>'.print_r($result, 1).'</pre>';
exit;*/
$cates = $conn->getAllCate();
//echo '<pre>'.print_r($cates, 1).'</pre>';

?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>首页</title>
    <link type="text/css" rel="stylesheet" href="styles/reset.css">
    <link type="text/css" rel="stylesheet" href="styles/main.css">
    <!--[if IE 6]>
    <script type="text/javascript" src="scripts/DD_belatedPNG_0.0.8a-min.js"></script>
    <script type="text/javascript" src="scripts/ie6Fixpng.js"></script>
    <![endif]-->
</head>
<body>
<div class="headerBar">
    <div class="topBar">
        <div class="comWidth">
            <div class="leftArea">
                <a href="#" class="collection">收藏本站</a>
            </div>
            <div class="rightArea">
                欢迎来到我的网站商城！
                <?php if(isset($_SESSION['login_id'])):?>
                    <span>欢迎您</span><?php echo $_SESSION['username'];?>
                    <a href="#">[退出]</a>
                <?php else:?>
                    <a href="login.php">[登录]</a><a href="#">[免费注册]</a>
                <?php endif;?>
            </div>
        </div>
    </div>
    <div class="logoBar">
        <div class="comWidth">
            <div class="logo fl">
                <a href="#"><img src="images/banner/banner01.jpg" width="100" height="50" alt="phpzhi"></a>
            </div>
            <div class="search_box fl">
                <input type="text" class="search_text fl"> <input type="button"
                                                                  value="搜 索" class="search_btn fr">
            </div>
            <div class="shopCar fr">
                <span class="shopText fl">购物车</span> <span class="shopNum fl">0</span>
            </div>
        </div>
    </div>
    <div class="navBox">
        <div class="comWidth clearfix">
            <div class="shopClass fl">
                <h3>
                    全部商品分类<i class="shopClass_icon"></i>
                </h3>
                <div class="shopClass_show">
                    <dl class="shopClass_item">
                        <dt>
                            <a href="#" class="b">手机</a> <a href="#" class="b">数码</a> <a
                                href="#" class="aLink">合约机</a>
                        </dt>
                        <dd>
                            <a href="#">荣耀3X</a> <a href="#">单反</a> <a href="#">智能设备</a>
                        </dd>
                    </dl>
                    <dl class="shopClass_item">
                        <dt>
                            <a href="#" class="b">手机</a> <a href="#" class="b">数码</a> <a
                                href="#" class="aLink">合约机</a>
                        </dt>
                        <dd>
                            <a href="#">荣耀3X</a> <a href="#">单反</a> <a href="#">智能设备</a>
                        </dd>
                    </dl>
                    <dl class="shopClass_item">
                        <dt>
                            <a href="#" class="b">手机</a> <a href="#" class="b">数码</a> <a
                                href="#" class="aLink">合约机</a>
                        </dt>
                        <dd>
                            <a href="#">荣耀3X</a> <a href="#">单反</a> <a href="#">智能设备</a>
                        </dd>
                    </dl>
                    <dl class="shopClass_item">
                        <dt>
                            <a href="#" class="b">手机</a> <a href="#" class="b">数码</a> <a
                                href="#" class="aLink">合约机</a>
                        </dt>
                        <dd>
                            <a href="#">荣耀3X</a> <a href="#">单反</a> <a href="#">智能设备</a>
                        </dd>
                    </dl>
                    <dl class="shopClass_item">
                        <dt>
                            <a href="#" class="b">手机</a> <a href="#" class="b">数码</a> <a
                                href="#" class="aLink">合约机</a>
                        </dt>
                        <dd>
                            <a href="#">荣耀3X</a> <a href="#">单反</a> <a href="#">智能设备</a>
                        </dd>
                    </dl>
                </div>
                <div class="shopClass_list hide">
                    <div class="shopClass_cont">
                        <dl class="shopList_item">
                            <dt>电脑装机</dt>
                            <dd>
                                <a href="#">文字啊</a><a href="#">文字字啊</a><a href="#">文字字字啊</a><a
                                    href="#">文字啊</a><a href="#">文字</a><a href="#">文字啊</a>
                            </dd>
                        </dl>
                        <dl class="shopList_item">
                            <dt>电脑装机</dt>
                            <dd>
                                <a href="#">文字啊</a><a href="#">文字字啊</a><a href="#">文字字字啊</a><a
                                    href="#">文字啊</a><a href="#">文字</a><a href="#">文字啊</a><a
                                    href="#">文字啊</a><a href="#">文字字啊</a><a href="#">文字字字啊</a><a
                                    href="#">文字啊</a><a href="#">文字</a><a href="#">文字啊</a><a
                                    href="#">文字啊</a>
                            </dd>
                        </dl>
                        <dl class="shopList_item">
                            <dt>电脑装机</dt>
                            <dd>
                                <a href="#">文字啊</a><a href="#">文字字啊</a><a href="#">文字字字啊</a><a
                                    href="#">文字啊</a><a href="#">文字</a><a href="#">文字啊</a><a
                                    href="#">文字啊</a><a href="#">文字字啊</a><a href="#">文字字字啊</a><a
                                    href="#">文字啊</a><a href="#">文字</a><a href="#">文字啊</a><a
                                    href="#">文字啊</a>
                            </dd>
                        </dl>
                        <dl class="shopList_item">
                            <dt>电脑装机</dt>
                            <dd>
                                <a href="#">文字啊</a><a href="#">文字字啊</a><a href="#">文字字字啊</a><a
                                    href="#">文字啊</a><a href="#">文字</a><a href="#">文字啊</a><a
                                    href="#">文字啊</a><a href="#">文字字啊</a><a href="#">文字字字啊</a><a
                                    href="#">文字啊</a><a href="#">文字</a><a href="#">文字啊</a><a
                                    href="#">文字啊</a>
                            </dd>
                        </dl>
                        <dl class="shopList_item">
                            <dt>电脑装机</dt>
                            <dd>
                                <a href="#">文字啊</a><a href="#">文字字啊</a><a href="#">文字字字啊</a><a
                                    href="#">文字啊</a><a href="#">文字</a><a href="#">文字啊</a><a
                                    href="#">文字啊</a><a href="#">文字字啊</a><a href="#">文字字字啊</a><a
                                    href="#">文字啊</a><a href="#">文字</a><a href="#">文字啊</a><a
                                    href="#">文字啊</a>
                            </dd>
                        </dl>
                        <div class="shopList_links">
                            <a href="#">文字测试内容等等<span></span></a><a href="#">文字容等等<span></span></a>
                        </div>
                    </div>
                </div>
            </div>
            <ul class="nav fl">
                <li><a href="#" class="active">数码城</a></li>
                <li><a href="#">天黑黑</a></li>
                <li><a href="#">团购</a></li>
                <li><a href="#">发现</a></li>
                <li><a href="#">二手特卖</a></li>
                <li><a href="#">名品会</a></li>
            </ul>
        </div>
    </div>
</div>
<div class="banner comWidth clearfix">
    <div class="banner_bar banner_big">
        <ul class="imgBox">
            <li><a href="#"><img src="images/banner/banner01.jpg" alt="banner"></a></li>
            <li><a href="#"><img src="images/banner/banner02.jpg" alt="banner"></a></li>
        </ul>
        <div class="imgNum">
            <a href="#" class="active"></a><a href="#"></a><a href="#"></a><a
                href="#"></a>
        </div>
    </div>
</div>
<?php foreach($cates as $cate):?>
    <div class="shopTit comWidth">
        <span class="icon"></span>
        <h3><?php echo $cate['cName'];?></h3>
        <a href="#" class="more">更多&gt;&gt;</a>
    </div>
    <div class="shopList comWidth clearfix">
        <div class="leftArea">
            <div class="banner_bar banner_sm">
                <ul class="imgBox">
                    <li><a href="#"><img src="images/banner/banner01.jpg"
                                         alt="banner"></a></li>
                    <li><a href="#"><img src="images/banner/banner01.jpg"
                                         alt="banner"></a></li>
                </ul>
                <div class="imgNum">
                    <a href="#" class="active"></a><a href="#"></a><a href="#"></a><a
                        href="#"></a>
                </div>
            </div>
        </div>
        <div class="rightArea">
            <div class="shopList_top clearfix">
                <?php
                $pros = $conn->getProsByCid($cate['id']);
                if ($pros && is_array($pros)) :
                    foreach ($pros as $pro) :
                        $proImg = $conn->getProImgById($pro['id']);
                        ?>
                        <div class="shop_item">
                            <div class="shop_img">
                                <a href="proDetails.php?id=<?php echo $pro['id'];?>"
                                   target="_blank"><img height="200" width="187"
                                                        src="images/banner/banner01.jpg" alt=""></a>
                            </div>
                            <h6><?php echo $pro['pName'];?></h6>
                            <p><?php echo $pro['iPrice'];?>元</p>
                        </div>
                        <?php
                    endforeach
                    ;

                endif;
                ?>

            </div>
            <div class="shopList_sm clearfix">
                <?php
                $prosSmall = $conn->getSmallProsByCid($cate['id']);
                if ($prosSmall && is_array($prosSmall)) :
                    foreach ($prosSmall as $proSmall) :
                        $proSmallImg = $conn->getProImgById($proSmall['id']);
                        ?>
                        <div class="shopItem_sm">
                            <div class="shopItem_smImg">
                                <a href="proDetails.php?id=<?php echo $proSmall['id'];?>"
                                   target="_blank"><img width="95" height="95"
                                                        src="images/banner/banner01.jpg" alt=""></a>
                            </div>
                            <div class="shopItem_text">
                                <p><?php echo $proSmall['pName'];?></p>
                                <h3>￥<?php echo $proSmall['iPrice'];?>	</h3>
                            </div>
                        </div>
                        <?php
                    endforeach
                    ;

                endif;
                ?>
            </div>
        </div>
    </div>
<?php endforeach;?>
<div class="hr_25"></div>
<div class="footer">
    <p>
        <a href="#">网站简介</a><i>|</i><a href="#">迷之公告</a><i>|</i> <a href="#">招纳贤士</a><i>|</i><a
            href="#">联系我们</a><i>|</i>客服热线：18269179369
    </p>
    <p>Copyright &copy; <?php echo date('Y')-1;?>-<?php echo date('Y');?>
        版权所有&nbsp;&nbsp;&nbsp;京ICP备09037834号&nbsp;&nbsp;&nbsp;京ICP证B1034-8373号&nbsp;&nbsp;&nbsp;某市公安局XX分局备案编号：123456789123</p>
    <p class="web">
        <a href="#"><img src="images/banner/banner01.jpg" width="100" height="50" alt="logo"></a><a href="#"><img
                src="images/banner/banner01.jpg" width="100" height="50" alt="logo"></a><a href="#"><img
                src="images/banner/banner01.jpg" width="100" height="50" alt="logo"></a><a href="#"><img
                src="images/banner/banner01.jpg" width="100" height="50" alt="logo"></a>
    </p>
</div>
</body>
</html>
